/**
 *
 * @Author：ming
 * @Date：2023/10/2 9:39 PM
 * @Filename：Hj8
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Objects;

/**
 * @author ming
 */
public class Hj19 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str ;
        LinkedList<Record> list = new LinkedList<>();
        while ((str=br.readLine())!=null){
            String[] split = str.split(" ");
            String initName = split[0].substring(split[0].lastIndexOf("\\")+1);
            String lastName = initName;
            if(initName.length()>16){
                lastName = initName.substring(initName.length()-16);
            }
            Integer row = Integer.valueOf(split[1]);
            Record record = new Record(lastName, row);
            if(list.contains(record)){
                int i = list.indexOf(record);
                Record record1 = list.get(i);
                record1.setCount(record1.getCount()+1);
            }else {
                record.setCount(1);
                list.add(record);
            }
        }
        int len = list.size();
        if(len>8){
            for (int i = len-8; i < len; i++) {
                Record record = list.get(i);
                System.out.println(record.getName()+" "+record.getNum()+" "+record.getCount());
            }
        }else {
            for (int i = 0; i < len; i++) {
                Record record = list.get(i);
                System.out.println(record.getName()+" "+record.getNum()+" "+record.getCount());

            }
        }



    }
}

class  Record{
    String name;
    Integer num;
    Integer count;

    public Record(String name, Integer num) {
        this.name = name;
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Record record = (Record) o;
        return name.equals(record.name) && num.equals(record.num);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, num);
    }
}
